﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MedReg
{
    public partial class Award
    {
        public void ImportList(List<Classes.Award> sAward)
        {
            var mdb = new MedregDBDataContext();
            
            foreach (var award in sAward)
            {
                Award award1 = new Award()
                {
                    Name = award.Name,
                    Issued = award.Issued,
                    Number = award.Number,
                    Employee = award.Employee.ID
                };

                IEnumerable<Award> query = (from aw in mdb.Award
                                where aw.Employee == award.Employee.ID
                                select aw
                                ).ToList();
                mdb.Award.DeleteAllOnSubmit(query);
                mdb.Award.InsertOnSubmit(award1);
            }
            mdb.SubmitChanges();
        }
    }
}
